<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>warnings - Perl pragma to control optional warnings - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/warnings">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="warnings.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/warnings">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/warnings">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/warnings">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/warnings">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/warnings">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/warnings">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/warnings">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/warnings">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/warnings">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/warnings">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/warnings">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/warnings">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/warnings">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/warnings">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/warnings">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/warnings">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/warnings">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/warnings">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/warnings">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/warnings">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/warnings">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/warnings">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/warnings">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/warnings">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/warnings">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/warnings">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/warnings">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/warnings">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/warnings">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/warnings">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/warnings">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/warnings">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/warnings">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/warnings">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/warnings">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/warnings">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/warnings">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/warnings">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/warnings">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/warnings">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/warnings">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/warnings">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/warnings">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/warnings">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/warnings">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/warnings">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/warnings">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/warnings">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/warnings">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/warnings">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/warnings">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/warnings">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/warnings">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/warnings">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/warnings">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/warnings">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/warnings">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/warnings">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/warnings">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/warnings">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/warnings">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/warnings">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/warnings">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/warnings">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/warnings">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/warnings">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/warnings">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/warnings">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/warnings">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/warnings">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/warnings">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/warnings">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/warnings">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/warnings">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/warnings">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/warnings">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/warnings">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/warnings">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/warnings">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/warnings">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="warnings.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/warnings">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/warnings">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/warnings">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/warnings">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/warnings">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/warnings">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/warnings">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/warnings">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/warnings">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/warnings">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/warnings">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/warnings">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/warnings">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/warnings">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/warnings">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/warnings">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/warnings">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/warnings">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/warnings">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/warnings">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/warnings">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/warnings">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/warnings">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/warnings">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/warnings">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/warnings">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/warnings">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/warnings">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/warnings">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/warnings">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/warnings">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/warnings">5.35.1</a>
          <a class="dropdown-item active" href="warnings.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="warnings.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="warnings.html">warnings</a>
          <div id="more">
            (<a href="warnings.txt">source</a>,
            <a href="https://metacpan.org/pod/warnings">CPAN</a>)
          </div>
            <div id="moduleversion">version 1.51</div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="warnings.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#DESCRIPTION">DESCRIPTION</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="warnings.html#Default-Warnings-and-Optional-Warnings">Default Warnings and Optional Warnings</a>
              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#%22Negative-warnings%22">&quot;Negative warnings&quot;</a>
              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#What&#39;s-wrong-with-w-and-$%5EW">What&#39;s wrong with -w and $^W</a>
              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#Controlling-Warnings-from-the-Command-Line">Controlling Warnings from the Command Line</a>
              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#Backward-Compatibility">Backward Compatibility</a>
              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#Category-Hierarchy">Category Hierarchy </a>
              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#Fatal-Warnings">Fatal Warnings </a>
              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#Reporting-Warnings-from-a-Module">Reporting Warnings from a Module  </a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="warnings.html#FUNCTIONS">FUNCTIONS</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="warnings.html#NAME">#</a>NAME</h1>

<p>warnings - Perl pragma to control optional warnings</p>

<h1 id="SYNOPSIS"><a class="permalink" href="warnings.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<pre><code>use warnings;
no warnings;

use warnings &quot;all&quot;;
no warnings &quot;uninitialized&quot;;

# or equivalent to those last two ...
use warnings qw(all -uninitialized);

use warnings::register;
if (warnings::enabled()) {
    warnings::warn(&quot;some warning&quot;);
}

if (warnings::enabled(&quot;void&quot;)) {
    warnings::warn(&quot;void&quot;, &quot;some warning&quot;);
}

if (warnings::enabled($object)) {
    warnings::warn($object, &quot;some warning&quot;);
}

warnings::warnif(&quot;some warning&quot;);
warnings::warnif(&quot;void&quot;, &quot;some warning&quot;);
warnings::warnif($object, &quot;some warning&quot;);</code></pre>

<h1 id="DESCRIPTION"><a class="permalink" href="warnings.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>The <code>warnings</code> pragma gives control over which warnings are enabled in which parts of a Perl program. It&#39;s a more flexible alternative for both the command line flag <b>-w</b> and the equivalent Perl variable, <code>$^W</code>.</p>

<p>This pragma works just like the <code>strict</code> pragma. This means that the scope of the warning pragma is limited to the enclosing block. It also means that the pragma setting will not leak across files (via <code>use</code>, <code>require</code> or <code>do</code>). This allows authors to independently define the degree of warning checks that will be applied to their module.</p>

<p>By default, optional warnings are disabled, so any legacy code that doesn&#39;t attempt to control the warnings will work unchanged.</p>

<p>All warnings are enabled in a block by either of these:</p>

<pre><code>use warnings;
use warnings &#39;all&#39;;</code></pre>

<p>Similarly all warnings are disabled in a block by either of these:</p>

<pre><code>no warnings;
no warnings &#39;all&#39;;</code></pre>

<p>For example, consider the code below:</p>

<pre><code>use warnings;
my @x;
{
    no warnings;
    my $y = @x[0];
}
my $z = @x[0];</code></pre>

<p>The code in the enclosing block has warnings enabled, but the inner block has them disabled. In this case that means the assignment to the scalar <code>$z</code> will trip the <code>&quot;Scalar value @x[0] better written as $x[0]&quot;</code> warning, but the assignment to the scalar <code>$y</code> will not.</p>

<h2 id="Default-Warnings-and-Optional-Warnings"><a class="permalink" href="warnings.html#Default-Warnings-and-Optional-Warnings">#</a><a id="Default"></a>Default Warnings and Optional Warnings</h2>

<p>Before the introduction of lexical warnings, Perl had two classes of warnings: mandatory and optional.</p>

<p>As its name suggests, if your code tripped a mandatory warning, you would get a warning whether you wanted it or not. For example, the code below would always produce an <code>&quot;isn&#39;t numeric&quot;</code> warning about the &quot;2:&quot;.</p>

<pre><code>my $x = &quot;2:&quot; + 3;</code></pre>

<p>With the introduction of lexical warnings, mandatory warnings now become <i>default</i> warnings. The difference is that although the previously mandatory warnings are still enabled by default, they can then be subsequently enabled or disabled with the lexical warning pragma. For example, in the code below, an <code>&quot;isn&#39;t numeric&quot;</code> warning will only be reported for the <code>$x</code> variable.</p>

<pre><code>my $x = &quot;2:&quot; + 3;
no warnings;
my $y = &quot;2:&quot; + 3;</code></pre>

<p>Note that neither the <b>-w</b> flag or the <code>$^W</code> can be used to disable/enable default warnings. They are still mandatory in this case.</p>

<h2 id="&quot;Negative-warnings&quot;"><a class="permalink" href="warnings.html#%22Negative-warnings%22">#</a><a id="Negative-warnings"></a>&quot;Negative warnings&quot;</h2>

<p>As a convenience, you can (as of Perl 5.34) pass arguments to the <code>import()</code> method both positively and negatively. Negative warnings are those with a <code>-</code> sign prepended to their names; positive warnings are anything else. This lets you turn on some warnings and turn off others in one command. So, assuming that you&#39;ve already turned on a bunch of warnings but want to tweak them a bit in some block, you can do this:</p>

<pre><code>{
    use warnings qw(uninitialized -redefine);
    ...
}</code></pre>

<p>which is equivalent to:</p>

<pre><code>{
    use warnings qw(uninitialized);
    no warnings qw(redefine);
    ...
}</code></pre>

<p>The argument list is processed in the order you specify. So, for example, if you don&#39;t want to be warned about use of experimental features, except for <code>somefeature</code> that you really dislike, you can say this:</p>

<pre><code>use warnings qw(all -experimental experimental::somefeature);</code></pre>

<p>which is equivalent to:</p>

<pre><code>use warnings &#39;all&#39;;
no warnings  &#39;experimental&#39;;
use warnings &#39;experimental::somefeature&#39;;</code></pre>

<h2 id="What&#39;s-wrong-with-w-and-$^W"><a class="permalink" href="warnings.html#What&#39;s-wrong-with-w-and-$%5EW">#</a><a id="What"></a><a id="Whats-wrong-with--w-and-W"></a>What&#39;s wrong with <b>-w</b> and <code>$^W</code></h2>

<p>Although very useful, the big problem with using <b>-w</b> on the command line to enable warnings is that it is all or nothing. Take the typical scenario when you are writing a Perl program. Parts of the code you will write yourself, but it&#39;s very likely that you will make use of pre-written Perl modules. If you use the <b>-w</b> flag in this case, you end up enabling warnings in pieces of code that you haven&#39;t written.</p>

<p>Similarly, using <code>$^W</code> to either disable or enable blocks of code is fundamentally flawed. For a start, say you want to disable warnings in a block of code. You might expect this to be enough to do the trick:</p>

<pre><code>{
    local ($^W) = 0;
    my $x =+ 2;
    my $y; chop $y;
}</code></pre>

<p>When this code is run with the <b>-w</b> flag, a warning will be produced for the <code>$x</code> line: <code>&quot;Reversed += operator&quot;</code>.</p>

<p>The problem is that Perl has both compile-time and run-time warnings. To disable compile-time warnings you need to rewrite the code like this:</p>

<pre><code>{
    BEGIN { $^W = 0 }
    my $x =+ 2;
    my $y; chop $y;
}</code></pre>

<p>And note that unlike the first example, this will permanently set <code>$^W</code> since it cannot both run during compile-time and be localized to a run-time block.</p>

<p>The other big problem with <code>$^W</code> is the way you can inadvertently change the warning setting in unexpected places in your code. For example, when the code below is run (without the <b>-w</b> flag), the second call to <code>doit</code> will trip a <code>&quot;Use of uninitialized value&quot;</code> warning, whereas the first will not.</p>

<pre><code>sub doit
{
    my $y; chop $y;
}

doit();

{
    local ($^W) = 1;
    doit()
}</code></pre>

<p>This is a side-effect of <code>$^W</code> being dynamically scoped.</p>

<p>Lexical warnings get around these limitations by allowing finer control over where warnings can or can&#39;t be tripped.</p>

<h2 id="Controlling-Warnings-from-the-Command-Line"><a class="permalink" href="warnings.html#Controlling-Warnings-from-the-Command-Line">#</a><a id="Controlling"></a>Controlling Warnings from the Command Line</h2>

<p>There are three Command Line flags that can be used to control when warnings are (or aren&#39;t) produced:</p>

<dl>

<dt id="-w"><a class="permalink" href="warnings.html#-w">#</a><a id="w"></a><b>-w</b> </dt>
<dd>

<p>This is the existing flag. If the lexical warnings pragma is <b>not</b> used in any of your code, or any of the modules that you use, this flag will enable warnings everywhere. See <a href="warnings.html#Backward-Compatibility">&quot;Backward Compatibility&quot;</a> for details of how this flag interacts with lexical warnings.</p>

</dd>
<dt id="-W"><a class="permalink" href="warnings.html#-W">#</a><a id="W"></a><b>-W</b> </dt>
<dd>

<p>If the <b>-W</b> flag is used on the command line, it will enable all warnings throughout the program regardless of whether warnings were disabled locally using <code>no warnings</code> or <code>$^W =0</code>. This includes all files that get included via <code>use</code>, <code>require</code> or <code>do</code>. Think of it as the Perl equivalent of the &quot;lint&quot; command.</p>

</dd>
<dt id="-X"><a class="permalink" href="warnings.html#-X">#</a><a id="X"></a><b>-X</b> </dt>
<dd>

<p>Does the exact opposite to the <b>-W</b> flag, i.e. it disables all warnings.</p>

</dd>
</dl>

<h2 id="Backward-Compatibility"><a class="permalink" href="warnings.html#Backward-Compatibility">#</a><a id="Backward"></a>Backward Compatibility</h2>

<p>If you are used to working with a version of Perl prior to the introduction of lexically scoped warnings, or have code that uses both lexical warnings and <code>$^W</code>, this section will describe how they interact.</p>

<p>How Lexical Warnings interact with <b>-w</b>/<code>$^W</code>:</p>

<ol>

<li><p>If none of the three command line flags (<b>-w</b>, <b>-W</b> or <b>-X</b>) that control warnings is used and neither <code>$^W</code> nor the <code>warnings</code> pragma are used, then default warnings will be enabled and optional warnings disabled. This means that legacy code that doesn&#39;t attempt to control the warnings will work unchanged.</p>

</li>
<li><p>The <b>-w</b> flag just sets the global <code>$^W</code> variable as in 5.005. This means that any legacy code that currently relies on manipulating <code>$^W</code> to control warning behavior will still work as is.</p>

</li>
<li><p>Apart from now being a boolean, the <code>$^W</code> variable operates in exactly the same horrible uncontrolled global way, except that it cannot disable/enable default warnings.</p>

</li>
<li><p>If a piece of code is under the control of the <code>warnings</code> pragma, both the <code>$^W</code> variable and the <b>-w</b> flag will be ignored for the scope of the lexical warning.</p>

</li>
<li><p>The only way to override a lexical warnings setting is with the <b>-W</b> or <b>-X</b> command line flags.</p>

</li>
</ol>

<p>The combined effect of 3 &amp; 4 is that it will allow code which uses the <code>warnings</code> pragma to control the warning behavior of $^W-type code (using a <code>local $^W=0</code>) if it really wants to, but not vice-versa.</p>

<h2 id="Category-Hierarchy"><a class="permalink" href="warnings.html#Category-Hierarchy">#</a><a id="Category"></a>Category Hierarchy </h2>

<p>A hierarchy of &quot;categories&quot; have been defined to allow groups of warnings to be enabled/disabled in isolation.</p>

<p>The current hierarchy is:</p>

<pre><code class="plaintext">all -+
     |
     +- closure
     |
     +- deprecated
     |
     +- exiting
     |
     +- experimental --+
     |                 |
     |                 +- experimental::alpha_assertions
     |                 |
     |                 +- experimental::bitwise
     |                 |
     |                 +- experimental::const_attr
     |                 |
     |                 +- experimental::declared_refs
     |                 |
     |                 +- experimental::isa
     |                 |
     |                 +- experimental::lexical_subs
     |                 |
     |                 +- experimental::postderef
     |                 |
     |                 +- experimental::private_use
     |                 |
     |                 +- experimental::re_strict
     |                 |
     |                 +- experimental::refaliasing
     |                 |
     |                 +- experimental::regex_sets
     |                 |
     |                 +- experimental::script_run
     |                 |
     |                 +- experimental::signatures
     |                 |
     |                 +- experimental::smartmatch
     |                 |
     |                 +- experimental::try
     |                 |
     |                 +- experimental::uniprop_wildcards
     |                 |
     |                 +- experimental::vlb
     |                 |
     |                 +- experimental::win32_perlio
     |
     +- glob
     |
     +- imprecision
     |
     +- io ------------+
     |                 |
     |                 +- closed
     |                 |
     |                 +- exec
     |                 |
     |                 +- layer
     |                 |
     |                 +- newline
     |                 |
     |                 +- pipe
     |                 |
     |                 +- syscalls
     |                 |
     |                 +- unopened
     |
     +- locale
     |
     +- misc
     |
     +- missing
     |
     +- numeric
     |
     +- once
     |
     +- overflow
     |
     +- pack
     |
     +- portable
     |
     +- recursion
     |
     +- redefine
     |
     +- redundant
     |
     +- regexp
     |
     +- severe --------+
     |                 |
     |                 +- debugging
     |                 |
     |                 +- inplace
     |                 |
     |                 +- internal
     |                 |
     |                 +- malloc
     |
     +- shadow
     |
     +- signal
     |
     +- substr
     |
     +- syntax --------+
     |                 |
     |                 +- ambiguous
     |                 |
     |                 +- bareword
     |                 |
     |                 +- digit
     |                 |
     |                 +- illegalproto
     |                 |
     |                 +- parenthesis
     |                 |
     |                 +- precedence
     |                 |
     |                 +- printf
     |                 |
     |                 +- prototype
     |                 |
     |                 +- qw
     |                 |
     |                 +- reserved
     |                 |
     |                 +- semicolon
     |
     +- taint
     |
     +- threads
     |
     +- uninitialized
     |
     +- unpack
     |
     +- untie
     |
     +- utf8 ----------+
     |                 |
     |                 +- non_unicode
     |                 |
     |                 +- nonchar
     |                 |
     |                 +- surrogate
     |
     +- void</code></pre>

<p>Just like the &quot;strict&quot; pragma any of these categories can be combined</p>

<pre><code>use warnings qw(void redefine);
no warnings qw(io syntax untie);</code></pre>

<p>Also like the &quot;strict&quot; pragma, if there is more than one instance of the <code>warnings</code> pragma in a given scope the cumulative effect is additive.</p>

<pre><code>use warnings qw(void); # only &quot;void&quot; warnings enabled
...
use warnings qw(io);   # only &quot;void&quot; &amp; &quot;io&quot; warnings enabled
...
no warnings qw(void);  # only &quot;io&quot; warnings enabled</code></pre>

<p>To determine which category a specific warning has been assigned to see <a href="perldiag.html">perldiag</a>.</p>

<p>Note: Before Perl 5.8.0, the lexical warnings category &quot;deprecated&quot; was a sub-category of the &quot;syntax&quot; category. It is now a top-level category in its own right.</p>

<p>Note: Before 5.21.0, the &quot;missing&quot; lexical warnings category was internally defined to be the same as the &quot;uninitialized&quot; category. It is now a top-level category in its own right.</p>

<h2 id="Fatal-Warnings"><a class="permalink" href="warnings.html#Fatal-Warnings">#</a><a id="Fatal"></a>Fatal Warnings </h2>

<p>The presence of the word &quot;FATAL&quot; in the category list will escalate warnings in those categories into fatal errors in that lexical scope.</p>

<p><b>NOTE:</b> FATAL warnings should be used with care, particularly <code>FATAL =&gt; &#39;all&#39;</code>.</p>

<p>Libraries using <a href="warnings.html#FUNCTIONS">warnings::warn</a> for custom warning categories generally don&#39;t expect <a href="warnings.html#FUNCTIONS">warnings::warn</a> to be fatal and can wind up in an unexpected state as a result. For XS modules issuing categorized warnings, such unanticipated exceptions could also expose memory leak bugs.</p>

<p>Moreover, the Perl interpreter itself has had serious bugs involving fatalized warnings. For a summary of resolved and unresolved problems as of January 2015, please see <a href="http://www.nntp.perl.org/group/perl.perl5.porters/2015/01/msg225235.html">this perl5-porters post</a>.</p>

<p>While some developers find fatalizing some warnings to be a useful defensive programming technique, using <code>FATAL =&gt; &#39;all&#39;</code> to fatalize all possible warning categories -- including custom ones -- is particularly risky. Therefore, the use of <code>FATAL =&gt; &#39;all&#39;</code> is <a href="perlpolicy.html#discouraged">discouraged</a>.</p>

<p>The <a href="strictures.html#VERSION-2">strictures</a> module on CPAN offers one example of a warnings subset that the module&#39;s authors believe is relatively safe to fatalize.</p>

<p><b>NOTE:</b> Users of FATAL warnings, especially those using <code>FATAL =&gt; &#39;all&#39;</code>, should be fully aware that they are risking future portability of their programs by doing so. Perl makes absolutely no commitments to not introduce new warnings or warnings categories in the future; indeed, we explicitly reserve the right to do so. Code that may not warn now may warn in a future release of Perl if the Perl5 development team deems it in the best interests of the community to do so. Should code using FATAL warnings break due to the introduction of a new warning we will NOT consider it an incompatible change. Users of FATAL warnings should take special caution during upgrades to check to see if their code triggers any new warnings and should pay particular attention to the fine print of the documentation of the features they use to ensure they do not exploit features that are documented as risky, deprecated, or unspecified, or where the documentation says &quot;so don&#39;t do that&quot;, or anything with the same sense and spirit. Use of such features in combination with FATAL warnings is ENTIRELY AT THE USER&#39;S RISK.</p>

<p>The following documentation describes how to use FATAL warnings but the perl5 porters strongly recommend that you understand the risks before doing so, especially for library code intended for use by others, as there is no way for downstream users to change the choice of fatal categories.</p>

<p>In the code below, the use of <code>time</code>, <code>length</code> and <code>join</code> can all produce a <code>&quot;Useless use of xxx in void context&quot;</code> warning.</p>

<pre><code>use warnings;

time;

{
    use warnings FATAL =&gt; qw(void);
    length &quot;abc&quot;;
}

join &quot;&quot;, 1,2,3;

print &quot;done\n&quot;;</code></pre>

<p>When run it produces this output</p>

<pre><code class="plaintext">Useless use of time in void context at fatal line 3.
Useless use of length in void context at fatal line 7.</code></pre>

<p>The scope where <code>length</code> is used has escalated the <code>void</code> warnings category into a fatal error, so the program terminates immediately when it encounters the warning.</p>

<p>To explicitly turn off a &quot;FATAL&quot; warning you just disable the warning it is associated with. So, for example, to disable the &quot;void&quot; warning in the example above, either of these will do the trick:</p>

<pre><code>no warnings qw(void);
no warnings FATAL =&gt; qw(void);</code></pre>

<p>If you want to downgrade a warning that has been escalated into a fatal error back to a normal warning, you can use the &quot;NONFATAL&quot; keyword. For example, the code below will promote all warnings into fatal errors, except for those in the &quot;syntax&quot; category.</p>

<pre><code>use warnings FATAL =&gt; &#39;all&#39;, NONFATAL =&gt; &#39;syntax&#39;;</code></pre>

<p>As of Perl 5.20, instead of <code>use warnings FATAL =&gt; &#39;all&#39;;</code> you can use:</p>

<pre><code>use v5.20;       # Perl 5.20 or greater is required for the following
use warnings &#39;FATAL&#39;;  # short form of &quot;use warnings FATAL =&gt; &#39;all&#39;;&quot;</code></pre>

<p>However, you should still heed the guidance earlier in this section against using <code>use warnings FATAL =</code> &#39;all&#39;;&gt;.</p>

<p>If you want your program to be compatible with versions of Perl before 5.20, you must use <code>use warnings FATAL =&gt; &#39;all&#39;;</code> instead. (In previous versions of Perl, the behavior of the statements <code>use warnings &#39;FATAL&#39;;</code>, <code>use warnings &#39;NONFATAL&#39;;</code> and <code>no warnings &#39;FATAL&#39;;</code> was unspecified; they did not behave as if they included the <code>=&gt; &#39;all&#39;</code> portion. As of 5.20, they do.)</p>

<h2 id="Reporting-Warnings-from-a-Module"><a class="permalink" href="warnings.html#Reporting-Warnings-from-a-Module">#</a><a id="Reporting"></a>Reporting Warnings from a Module  </h2>

<p>The <code>warnings</code> pragma provides a number of functions that are useful for module authors. These are used when you want to report a module-specific warning to a calling module has enabled warnings via the <code>warnings</code> pragma.</p>

<p>Consider the module <code>MyMod::Abc</code> below.</p>

<pre><code>package MyMod::Abc;

use warnings::register;

sub open {
    my $path = shift;
    if ($path !~ m#^/#) {
        warnings::warn(&quot;changing relative path to /var/abc&quot;)
            if warnings::enabled();
        $path = &quot;/var/abc/$path&quot;;
    }
}

1;</code></pre>

<p>The call to <code>warnings::register</code> will create a new warnings category called &quot;MyMod::Abc&quot;, i.e. the new category name matches the current package name. The <code>open</code> function in the module will display a warning message if it gets given a relative path as a parameter. This warnings will only be displayed if the code that uses <code>MyMod::Abc</code> has actually enabled them with the <code>warnings</code> pragma like below.</p>

<pre><code>use MyMod::Abc;
use warnings &#39;MyMod::Abc&#39;;
...
abc::open(&quot;../fred.txt&quot;);</code></pre>

<p>It is also possible to test whether the pre-defined warnings categories are set in the calling module with the <code>warnings::enabled</code> function. Consider this snippet of code:</p>

<pre><code>package MyMod::Abc;

sub open {
    if (warnings::enabled(&quot;deprecated&quot;)) {
        warnings::warn(&quot;deprecated&quot;,
                       &quot;open is deprecated, use new instead&quot;);
    }
    new(@_);
}

sub new
...
1;</code></pre>

<p>The function <code>open</code> has been deprecated, so code has been included to display a warning message whenever the calling module has (at least) the &quot;deprecated&quot; warnings category enabled. Something like this, say.</p>

<pre><code>use warnings &#39;deprecated&#39;;
use MyMod::Abc;
...
MyMod::Abc::open($filename);</code></pre>

<p>Either the <code>warnings::warn</code> or <code>warnings::warnif</code> function should be used to actually display the warnings message. This is because they can make use of the feature that allows warnings to be escalated into fatal errors. So in this case</p>

<pre><code>use MyMod::Abc;
use warnings FATAL =&gt; &#39;MyMod::Abc&#39;;
...
MyMod::Abc::open(&#39;../fred.txt&#39;);</code></pre>

<p>the <code>warnings::warnif</code> function will detect this and die after displaying the warning message.</p>

<p>The three warnings functions, <code>warnings::warn</code>, <code>warnings::warnif</code> and <code>warnings::enabled</code> can optionally take an object reference in place of a category name. In this case the functions will use the class name of the object as the warnings category.</p>

<p>Consider this example:</p>

<pre><code>package Original;

no warnings;
use warnings::register;

sub new
{
    my $class = shift;
    bless [], $class;
}

sub check
{
    my $self = shift;
    my $value = shift;

    if ($value % 2 &amp;&amp; warnings::enabled($self))
      { warnings::warn($self, &quot;Odd numbers are unsafe&quot;) }
}

sub doit
{
    my $self = shift;
    my $value = shift;
    $self-&gt;check($value);
    # ...
}

1;

package Derived;

use warnings::register;
use Original;
our @ISA = qw( Original );
sub new
{
    my $class = shift;
    bless [], $class;
}


1;</code></pre>

<p>The code below makes use of both modules, but it only enables warnings from <code>Derived</code>.</p>

<pre><code>use Original;
use Derived;
use warnings &#39;Derived&#39;;
my $x = Original-&gt;new();
$x-&gt;doit(1);
my $y = Derived-&gt;new();
$x-&gt;doit(1);</code></pre>

<p>When this code is run only the <code>Derived</code> object, <code>$y</code>, will generate a warning.</p>

<pre><code class="plaintext">Odd numbers are unsafe at main.pl line 7</code></pre>

<p>Notice also that the warning is reported at the line where the object is first used.</p>

<p>When registering new categories of warning, you can supply more names to warnings::register like this:</p>

<pre><code>package MyModule;
use warnings::register qw(format precision);

...

warnings::warnif(&#39;MyModule::format&#39;, &#39;...&#39;);</code></pre>

<h1 id="FUNCTIONS"><a class="permalink" href="warnings.html#FUNCTIONS">#</a>FUNCTIONS</h1>

<p>Note: The functions with names ending in <code>_at_level</code> were added in Perl 5.28.</p>

<dl>

<dt id="use-warnings::register"><a class="permalink" href="warnings.html#use-warnings::register">#</a><a id="use"></a>use warnings::register</dt>
<dd>

<p>Creates a new warnings category with the same name as the package where the call to the pragma is used.</p>

</dd>
<dt id="warnings::enabled()"><a class="permalink" href="warnings.html#warnings::enabled()">#</a><a id="warnings"></a><a id="warnings::enabled"></a>warnings::enabled()</dt>
<dd>

<p>Use the warnings category with the same name as the current package.</p>

<p>Return TRUE if that warnings category is enabled in the calling module. Otherwise returns FALSE.</p>

</dd>
<dt id="warnings::enabled($category)"><a class="permalink" href="warnings.html#warnings::enabled($category)">#</a><a id="warnings1"></a><a id="warnings::enabled-category"></a>warnings::enabled($category)</dt>
<dd>

<p>Return TRUE if the warnings category, <code>$category</code>, is enabled in the calling module. Otherwise returns FALSE.</p>

</dd>
<dt id="warnings::enabled($object)"><a class="permalink" href="warnings.html#warnings::enabled($object)">#</a><a id="warnings2"></a><a id="warnings::enabled-object"></a>warnings::enabled($object)</dt>
<dd>

<p>Use the name of the class for the object reference, <code>$object</code>, as the warnings category.</p>

<p>Return TRUE if that warnings category is enabled in the first scope where the object is used. Otherwise returns FALSE.</p>

</dd>
<dt id="warnings::enabled_at_level($category,-$level)"><a class="permalink" href="warnings.html#warnings::enabled_at_level($category,-$level)">#</a><a id="warnings3"></a><a id="warnings::enabled_at_level-category-level"></a>warnings::enabled_at_level($category, $level)</dt>
<dd>

<p>Like <code>warnings::enabled</code>, but $level specifies the exact call frame, 0 being the immediate caller.</p>

</dd>
<dt id="warnings::fatal_enabled()"><a class="permalink" href="warnings.html#warnings::fatal_enabled()">#</a><a id="warnings4"></a><a id="warnings::fatal_enabled"></a>warnings::fatal_enabled()</dt>
<dd>

<p>Return TRUE if the warnings category with the same name as the current package has been set to FATAL in the calling module. Otherwise returns FALSE.</p>

</dd>
<dt id="warnings::fatal_enabled($category)"><a class="permalink" href="warnings.html#warnings::fatal_enabled($category)">#</a><a id="warnings5"></a><a id="warnings::fatal_enabled-category"></a>warnings::fatal_enabled($category)</dt>
<dd>

<p>Return TRUE if the warnings category <code>$category</code> has been set to FATAL in the calling module. Otherwise returns FALSE.</p>

</dd>
<dt id="warnings::fatal_enabled($object)"><a class="permalink" href="warnings.html#warnings::fatal_enabled($object)">#</a><a id="warnings6"></a><a id="warnings::fatal_enabled-object"></a>warnings::fatal_enabled($object)</dt>
<dd>

<p>Use the name of the class for the object reference, <code>$object</code>, as the warnings category.</p>

<p>Return TRUE if that warnings category has been set to FATAL in the first scope where the object is used. Otherwise returns FALSE.</p>

</dd>
<dt id="warnings::fatal_enabled_at_level($category,-$level)"><a class="permalink" href="warnings.html#warnings::fatal_enabled_at_level($category,-$level)">#</a><a id="warnings7"></a><a id="warnings::fatal_enabled_at_level-category-level"></a>warnings::fatal_enabled_at_level($category, $level)</dt>
<dd>

<p>Like <code>warnings::fatal_enabled</code>, but $level specifies the exact call frame, 0 being the immediate caller.</p>

</dd>
<dt id="warnings::warn($message)"><a class="permalink" href="warnings.html#warnings::warn($message)">#</a><a id="warnings8"></a><a id="warnings::warn-message"></a>warnings::warn($message)</dt>
<dd>

<p>Print <code>$message</code> to STDERR.</p>

<p>Use the warnings category with the same name as the current package.</p>

<p>If that warnings category has been set to &quot;FATAL&quot; in the calling module then die. Otherwise return.</p>

</dd>
<dt id="warnings::warn($category,-$message)"><a class="permalink" href="warnings.html#warnings::warn($category,-$message)">#</a><a id="warnings9"></a><a id="warnings::warn-category-message"></a>warnings::warn($category, $message)</dt>
<dd>

<p>Print <code>$message</code> to STDERR.</p>

<p>If the warnings category, <code>$category</code>, has been set to &quot;FATAL&quot; in the calling module then die. Otherwise return.</p>

</dd>
<dt id="warnings::warn($object,-$message)"><a class="permalink" href="warnings.html#warnings::warn($object,-$message)">#</a><a id="warnings10"></a><a id="warnings::warn-object-message"></a>warnings::warn($object, $message)</dt>
<dd>

<p>Print <code>$message</code> to STDERR.</p>

<p>Use the name of the class for the object reference, <code>$object</code>, as the warnings category.</p>

<p>If that warnings category has been set to &quot;FATAL&quot; in the scope where <code>$object</code> is first used then die. Otherwise return.</p>

</dd>
<dt id="warnings::warn_at_level($category,-$level,-$message)"><a class="permalink" href="warnings.html#warnings::warn_at_level($category,-$level,-$message)">#</a><a id="warnings11"></a><a id="warnings::warn_at_level-category-level-message"></a>warnings::warn_at_level($category, $level, $message)</dt>
<dd>

<p>Like <code>warnings::warn</code>, but $level specifies the exact call frame, 0 being the immediate caller.</p>

</dd>
<dt id="warnings::warnif($message)"><a class="permalink" href="warnings.html#warnings::warnif($message)">#</a><a id="warnings12"></a><a id="warnings::warnif-message"></a>warnings::warnif($message)</dt>
<dd>

<p>Equivalent to:</p>

<pre><code>if (warnings::enabled())
  { warnings::warn($message) }</code></pre>

</dd>
<dt id="warnings::warnif($category,-$message)"><a class="permalink" href="warnings.html#warnings::warnif($category,-$message)">#</a><a id="warnings13"></a><a id="warnings::warnif-category-message"></a>warnings::warnif($category, $message)</dt>
<dd>

<p>Equivalent to:</p>

<pre><code>if (warnings::enabled($category))
  { warnings::warn($category, $message) }</code></pre>

</dd>
<dt id="warnings::warnif($object,-$message)"><a class="permalink" href="warnings.html#warnings::warnif($object,-$message)">#</a><a id="warnings14"></a><a id="warnings::warnif-object-message"></a>warnings::warnif($object, $message)</dt>
<dd>

<p>Equivalent to:</p>

<pre><code>if (warnings::enabled($object))
  { warnings::warn($object, $message) }</code></pre>

</dd>
<dt id="warnings::warnif_at_level($category,-$level,-$message)"><a class="permalink" href="warnings.html#warnings::warnif_at_level($category,-$level,-$message)">#</a><a id="warnings15"></a><a id="warnings::warnif_at_level-category-level-message"></a>warnings::warnif_at_level($category, $level, $message)</dt>
<dd>

<p>Like <code>warnings::warnif</code>, but $level specifies the exact call frame, 0 being the immediate caller.</p>

</dd>
<dt id="warnings::register_categories(@names)"><a class="permalink" href="warnings.html#warnings::register_categories(@names)">#</a><a id="warnings16"></a><a id="warnings::register_categories-names"></a>warnings::register_categories(@names)</dt>
<dd>

<p>This registers warning categories for the given names and is primarily for use by the warnings::register pragma.</p>

</dd>
</dl>

<p>See also <a href="perlmodlib.html#Pragmatic-Modules">&quot;Pragmatic Modules&quot; in perlmodlib</a> and <a href="perldiag.html">perldiag</a>.</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
